/*
 * =====================================================================================
 *
 *       Filename:  point3d.h
 *
 *    Description:  3d point
 *
 *        Version:  1.0
 *        Created:  2009年07月17日 10时48分54秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Ying Wang (WY), ywang@nlpr.ia.ac.cn
 *        Company:  Institute of Automation, Chinese Academy of Sciences
 *
 * =====================================================================================
 */
#ifndef POINT3D_H
#define POINT3D_H
#include <iostream>

template<typename T>
class NCpoint3D
{

	template<typename T1>
		friend std::ostream& operator << (std::ostream& os, const NCpoint3D<T1>& point3d);
	template<typename T1>
		friend bool operator == ( const NCpoint3D<T1>& p1, const NCpoint3D<T1>& p2 );
public:
	NCpoint3D();
	NCpoint3D( const T &x, const T &y, const T &z );
	NCpoint3D( const NCpoint3D<T> &point3d);
public:
	inline NCpoint3D<T>& operator = (const NCpoint3D<T> &point3d);

public:
	inline T x() const {return m_x;}
	inline T y() const {return m_y;}
	inline T z() const {return m_z;}
public:
	inline void setX(const T &x){m_x = x;}
	inline void setY(const T &y){m_y = y;}
	inline void setZ(const T &z){m_z = z;}
private:
	T m_x;
	T m_y;
	T m_z;
};


template<typename T>
NCpoint3D<T> :: NCpoint3D()
	: m_x(0)
	, m_y(0)
	, m_z(0)
{
}

template<typename T>
NCpoint3D<T> :: NCpoint3D( const T &x, const T &y, const T &z)
	: m_x(x)
	, m_y(y)
	, m_z(z)
{
}

template<typename T>
NCpoint3D<T> :: NCpoint3D( const NCpoint3D<T> &point3d )
	: m_x(point3d.m_x)
	, m_y(point3d.m_y)
	, m_z(point3d.m_z)
{
}

template<typename T>
inline NCpoint3D<T>& NCpoint3D<T> :: operator = ( const NCpoint3D<T> &point3d )
{
	if( this != & point3d )
	{
		m_x = point3d.m_x;
		m_y = point3d.m_y;
		m_z = point3d.m_z;
	}
	return *this;
}

template<typename T1>
std::ostream& operator << (std::ostream& os, const NCpoint3D<T1>& point3d)
{
	os<<point3d.m_x<<" "<<point3d.m_y<<" "<<point3d.m_y;
	return os;
}

template<typename T1>
bool operator == ( const NCpoint3D<T1>& p1, const NCpoint3D<T1>& p2 )
{
	return (p1.m_x == p2.m_x) && (p1.m_y == p2.m_y) && (p1.m_z == p2.m_z);
}
#endif
